module(..., package.seeall)

--暂时不弄传参，方向 ：上黑下淡
local kernelGradualSqrt = {} --渐变 开3次
kernelGradualSqrt.category = "filter"
kernelGradualSqrt.name = "gradient_sqrt3"
kernelGradualSqrt.fragment = [[

P_COLOR vec4 FragmentKernel( P_UV vec2 texCoord )
    {
	 	P_COLOR vec4 texColor = texture2D( CoronaSampler0, texCoord );
	    texColor.a -=   pow(texCoord.y,1.0/3.0)  ;
		return CoronaColorScale(texColor);  
    }
]]



--暂时不弄传参，方向 ：上淡下黑
local kernelGradualSin = {} --渐变 sin
kernelGradualSin.category = "filter"
kernelGradualSin.name = "gradient_sin"
kernelGradualSin.fragment = [[

    P_COLOR vec4 FragmentKernel( P_UV vec2 texCoord )
    {
	 	P_COLOR vec4 texColor = texture2D( CoronaSampler0, texCoord );
	  	//texColor.a -= sin( (texCoord.y+1.0)*1.5707963 );//sin 1/4周期的渐变
	  	texColor.rgba -= sin( (texCoord.y+1.0)*1.5707963 );//sin 1/4周期的渐变

		return CoronaColorScale(texColor);  
    }
]]


local kernelGradualXY = {}
kernelGradualXY.category = "generator"
kernelGradualXY.name = "gradientRect__"
kernelGradualXY.isTimeDependent = true
kernelGradualXY.fragment =
[[ 	
	P_COLOR vec4 FragmentKernel( P_UV vec2 texCoord )
	{	
		P_COLOR vec4 texColor = vec4(0.0); 
		texColor.rgba  +=    (1.0-distance(vec2(0.5,1.0),vec2(texCoord.x+0.7 , texCoord.y+0.1) ))*0.5;
	    return CoronaColorScale( texColor );  
	}
]]




function load()
	if not globalGroup.shaderRecoder[kernelGradualSin.name] then
		graphics.defineEffect( kernelGradualSin )
		globalGroup.shaderRecoder[kernelGradualSin.name] = true
	end

	if not globalGroup.shaderRecoder[kernelGradualSqrt.name] then
		graphics.defineEffect( kernelGradualSqrt )
		globalGroup.shaderRecoder[kernelGradualSqrt.name] = true
	end

	if not globalGroup.shaderRecoder[kernelGradualXY.name] then
		graphics.defineEffect( kernelGradualXY )
		globalGroup.shaderRecoder[kernelGradualXY.name] = true
	end
end